﻿using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using SqlSugar;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities.Events;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Guids;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Users;
using Volo.Abp;
using Microsoft.Extensions.DependencyInjection;
using Framework.SqlSugarCore.Abstractions;
using Volo.Abp.Auditing;
using Yitter.IdGenerator;

namespace Framework.SqlSugarCore
{
	/// <summary>
	/// 数据库上下文
	/// </summary>
	public class SqlSugarDbContext : ISqlSugarDbContextDependencies
	{
		protected IAbpLazyServiceProvider LazyServiceProvider { get; }

		public SqlSugarDbContext(IAbpLazyServiceProvider lazyServiceProvider)
		{
			this.LazyServiceProvider = lazyServiceProvider;
		}

		protected ISqlSugarClient SqlSugarClient { get; private set; }
		public int ExecutionOrder => 0;

		public void OnSqlSugarClientConfig(ISqlSugarClient sqlSugarClient)
		{
			SqlSugarClient = sqlSugarClient;
			CustomDataFilter(sqlSugarClient);
		}
		protected virtual void CustomDataFilter(ISqlSugarClient sqlSugarClient)
		{
		}

		public virtual void DataExecuted(object oldValue, DataAfterModel entityInfo)
		{
		}

		public virtual void DataExecuting(object oldValue, DataFilterModel entityInfo)
		{
		}

		public virtual void OnLogExecuting(string sql, SugarParameter[] pars)
		{
		}

		public virtual void OnLogExecuted(string sql, SugarParameter[] pars)
		{
		}

		public virtual void EntityService(PropertyInfo propertyInfo, EntityColumnInfo entityColumnInfo)
		{
		}
	}
}
